<?php
require_once('admin/config.php');
require_once ('include/convertm.php');

$order_id = $_GET['order_id'];
$pdo = $conn->prepare('SELECT order_id, datab_product.product_id, product_name, product_price, order_quantity FROM datab_order_product JOIN datab_product ON datab_order_product.product_id=datab_product.product_id  WHERE order_id=?');
$pdo->execute(array($order_id));
if ($pdo->rowCount()) {
    $data = $pdo->fetchAll();
}
?>
<style type='text/css'>
.list{	border-collapse:collapse;	width: 100%;	border-top:1px solid #ccc;	border-left:1px solid #ccc;	margin-bottom:20px;}
.list td, th{	border-bottom:1px solid #ccc;	border-right:1px solid #ccc;	padding:5px 2px 3px 5px;}
</style>
<link rel='stylesheet' type='text/css' href='css/style_list.css'/>
<div class="box">
    <div class="box-heading">Đơn hàng</div>
    <div class="box-content">
        <table class="list">
            <tr bgcolor="#EFEFEF">
                <td class="name">Tên món ăn</td>
                <td class="quantity">Số lượng</td>
                <td class="quantity">Giá</td>
                <td class="quantity">Thành tiền</td>
            </tr>
            <?php
            if (isset($data) && count($data)) {
                $total = 0;
                foreach ($data as $row) {
                    $total += $row['order_quantity'] * $row['product_price'];
                    ?>
                    <tr>
                        <td class="name"><?php echo $row['product_name']; ?></td>
                        <td class="quantity"><?php echo $row['order_quantity']; ?></td>
                        <td class="quantity"><?php echo formatMoney($row['product_price']); ?></td>
                        <td class="quantity"><?php echo formatMoney($row['order_quantity'] * $row['product_price']); ?></td>
                    </tr>    
                    <?php
                }
            }
            ?>
            <tr>
                <td colspan='3'><font style='color: red;'>Tổng tiền</font></td>
                <td class="quantity"><font style='color: red;'><?php echo formatMoney($total); ?></font></td>
            </tr>
        </table>
    </div>
</div>    

